<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
	<title data-localize="statistics_print.printanalysisone">印刷机分析一</title>
<link rel="stylesheet" type="text/css" href="css/common.css">
<style type="text/css">
.u-container{
	position: relative;
	width: 100%;
	height: 140px;
	margin: 0 auto;
	margin-top: 40px;
	overflow-x: hidden;
	overflow-y: auto;
}
.u-container .machine:hover{
	background: #29abe2;
}
.u-container p{
	display: none;
}
.machine{
	float: left;
	height: 130px;
	text-align: center;
}
.machine img{
	height: 100%;
}
.undone{
	-webkit-filter: grayscale(100%); /* Chrome, Safari, Opera */
    filter: grayscale(100%);
    background: #d0d0d0;
}
.u-datacon{
	position: relative;
	width: 100%;
	height: 840px;
}
.u-leftline{
	position: relative;
	width: 50%;
	height: 540px;
	float: left;
}
.u-chartcon{
	position: relative;
	float: left;
	width: 900px;
	height: 900px;
	margin-top: 40px;
	margin-left: 100px;
	text-align: center;
	overflow: hidden;
}
.u-chart{
	position: relative;
	float: left;
	width: 100%;
	height: 300px;
	margin: 172px 0 0 26px;
	border-left: 1px solid #aaa;
	border-bottom: 1px solid #aaa;
}
.u-chartleft{
	position: absolute;
	display: block;
	height: 100%;
	width: 20px;
	left: -22px;
	top: 0;
}
.u-changetime{
	width: 100%;
	height: 30px;
}
.u-changetime input.datainp{
	text-indent: 7px;
	height: 27px;
	width: 170px;
	-webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
	border: 1px solid #d0d0d0;
	margin-left: 4px;
}
.u-start{
	float: left;
	margin-left: 90px;
}
.u-start label,.u-end label{
	display: inline-block;
	text-align: left;
	width: 100px;
}
.u-end{
	float: left;
	margin-left: 10px;
}
.u-auto{
	line-height: 27px;
}
.u-chartbottom{
	position: absolute;
	display: block;
	width: 40px;
	height: 20px;
	line-height: 20px;
	margin: 0;
	left: -30px;
	bottom: -22px;
}
.u-chartbars{
	float: left;
	position: relative;
	height: 100%;
	width: 20px;
	margin-left: 20px;
	-webkit-transform: rotateX(180deg);
}
.u-chartbars .u-mname{
	position: absolute;
	left: -15px;
	top: -16px;
	line-height: 16px;
	width: 50px;
	font-size: 12px;
	-webkit-transform: rotateX(-180deg);
}
.u-product{
	float: left;
	height: 46px;
	width: 100%;
	bottom: 0;
	left: 0;
	background: #f5d73e;
}
.u-break{
	float: left;
	width: 100%;
	height: 20px;
	background: #f44336;
}
.u-error{
	float: left;
	width: 100%;
	height: 20px;
	background: #009fff;
}
.u-chartbars:nth-child(1) .u-product{
	height: 70%;
}
.u-chartbars:nth-child(2) .u-product{
	height: 20%;
}
.u-chartbars:nth-child(3) .u-product{
	height: 50%;
}
.u-chartbars:nth-child(4) .u-product{
	height: 90%;
}
.u-chartbars:nth-child(5) .u-product{
	height: 40%;
}
.u-xm{
	width: 100%;
	margin-top: 20px;
	text-align: left;
}
.u-xm label{
	width: 100px;
	display: inline-block;
}
.u-xm select{
	width: 170px;
	height: 30px;
	-webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
	border: 1px solid #d0d0d0;
}
.loading{
    background-color: rgba(255,255,255,0.9);
    background-position: center center;
    width: 100%;
    height: 100%;
    background-image: url("image/loading.gif");
    position: absolute;
    left: 0;
    top: 0;
    z-index: 10000;
    background-repeat: no-repeat;
}
.selectTitle{
	display: block;
	margin-bottom: 10px;
	text-align: left;
	margin-left: 50px;
	background: #f4f4f4;
	padding: 10px;
	padding-left: 50px;
	border-radius: 5px;
}
.selectTitle select{
	border: 1px solid #d0d0d0;
	border-radius: 5px;
	height: 30px;
	margin-left: 60px;
	width: 170px;

}
</style>
<link rel="stylesheet" type="text/css" href="css/machine.css">
<link rel="stylesheet" type="text/css" href="js/jedate/jedate.css">
</head>
<body>
<div class="loading"></div>
<div class='u-head'>
   <div class="u-headcon">
	<a href="index.html"><div class="u-mainpage" data-localize="statistics_print.backindex">回到首页</div></a>
	<h3 data-localize="statistics_print.printanalysisone">印刷机分析一</h3>
	   <div class="changeLang">
		   <p class="u-lang"><span>中文</span><span>English</span></p>
		   <div isopen="true" class="changeLangBtn"></div>
	   </div>
</div>
</div>

<div class="u-datacon">
	<div class="u-chartcon">
		<div class="selectTitle">
			<label data-localize="statistics_print.item">项目</label>
			<select class="selectType" onchange="sel_type()">
				<option value ="2" data-localize="statistics_print.hour">按小时</option>
				<option value ="3" data-localize="statistics_print.minute">按分</option>
				<option value ="1" data-localize="statistics_print.piece">按片</option>
			</select>
		</div>

		<!-- 按片 -->
		<div class="u-changetime part-changetime" hidden>
			<div class="u-start"><label data-localize="statistics_print.begintime">开始时间</label><input type="text" class="datainp startDate1" readonly/></div>
			<div class="u-end"><label data-localize="statistics_print.endtime">结束时间</label><input type="text" class="datainp endDate1" readonly/></div>
			<div class="u-auto"><input type="checkbox" class="chooseAB"><span data-localize="statistics_print.chooseAB">AB选择</span></div>
		</div>
		<div class="u-changetime part-changetime" hidden style="margin-top: 20px;">
			<div class="u-start"><label data-localize="statistics_print.begintime">开始时间</label><input type="text" class="datainp startDate2" disabled/></div>
			<div class="u-end"><label data-localize="statistics_print.endtime">结束时间</label><input type="text" class="datainp endDate2" disabled/></div>
		</div>

		<!-- 按小时 -->
		<div class="u-changetime hour-changetime" >
			<div class="u-start"><label data-localize="statistics_print.begintime">开始时间</label><input type="text" class="datainp startDate3" readonly/></div>
			<div class="u-end"><label data-localize="statistics_print.endtime">结束时间</label><input type="text" class="datainp endDate3" readonly/></div>
			<div class="u-auto"><input type="checkbox" class="chooseAB" ><span data-localize="statistics_print.chooseAB">AB选择</span></div>
		</div>
		<div class="u-changetime hour-changetime" style="margin-top: 20px;">
			<div class="u-start"><label data-localize="statistics_print.begintime">开始时间</label><input type="text" class="datainp startDate4" disabled/></div>
			<div class="u-end"><label data-localize="statistics_print.endtime">结束时间</label><input type="text" class="datainp endDate4" disabled/></div>
		</div>

		<!-- 按秒 -->
		<div class="u-changetime sec-changetime" hidden>
			<div class="u-start"><label data-localize="statistics_print.begintime">开始时间</label><input type="text" class="datainp startDate5" readonly/></div>
			<div class="u-end"><label data-localize="statistics_print.endtime">结束时间</label><input type="text" class="datainp endDate5" readonly/></div>
			<div class="u-auto"><input type="checkbox" class="chooseAB" ><span data-localize="statistics_print.chooseAB">AB选择</span></div>
		</div>
		<div class="u-changetime sec-changetime" hidden style="margin-top: 20px;">
			<div class="u-start"><label data-localize="statistics_print.begintime">开始时间</label><input type="text" class="datainp startDate6" disabled/></div>
			<div class="u-end"><label data-localize="statistics_print.endtime">结束时间</label><input type="text" class="datainp endDate6" disabled/></div>
		</div>

		<div class="u-xm">
			<label style="margin-left: 90px;" data-localize="statistics_print.line">产线</label>
			<select class="u-selectLine">
			</select>
			<br><br>
			<label style="margin-left: 90px;" data-localize="statistics_print.item">项目</label>
			<select class="type u-xiangmu">
				<option value ="1" data-localize="statistics_print.gratinglinewidth">栅线宽度</option>
				<option value ="2" data-localize="statistics_print.wetweight">湿重</option>
				<option value ="3" data-localize="statistics_print.uoc">短路电流</option>
				<option value ="4" data-localize="statistics_print.eta">效率</option>
				<option value ="5" data-localize="statistics_print.ff">填充</option>
			</select>

			<label class="u-xiangmu2" style="margin-left: 7px;" data-localize="statistics_print.other">其他</label>
			<select class="type1 u-xiangmu2">
				<option value ="1">1</option>
				<option value ="2">2</option>
				<option value ="3">3</option>
				<option value ="4">4</option>
			</select>
			<a class="u-downloadCSV" id="downloadCSV" style="margin-left: 10px;"><div class="u-btnblue" data-localize="statistics_print.downloadCSV">导出CSV</div></a>
			<div class="u-btnblue u-confirmbtn" data-localize="statistics_print.confirm">确认</div>
		</div>
		<div id='canvasDiv'></div>
	</div>
</div>

<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/jquery.localize.min.js" charset="utf-8"></script>
<script type="text/javascript" src="js/language_cookie.js" charset="utf-8"></script>
<script type="text/javascript" src="js/ichart.1.2.1.min.js"></script>
<script type="text/javascript" src="js/jedate/jquery.jedate.js"></script>
<script type="text/javascript">
var chart;
var csvData;
var data;


var labela = [],labelb=[];

$(function() {
    csvData = {
        header: ['产线ID','设备ID','设备名','硅片id','项目','项目值','时间'],
        body: []
    };
    data = [{
        name: '',
        value: [null],
        color: '#0d8ecf',
        line_width: 2,
        texta:"平均值A："
    }, {
        name: '',
        value: [null],
        color: '#ef7707',
        line_width: 2,
        textb:"平均值B："
    }];
    $(".loading").hide();
	labela[0] = $('.startDate1').val();
    labela[1] = $('.endDate1').val();
    chart = new iChart.LineBasic2D({
		render: 'canvasDiv',
		animation:false,
		data: data,
		align: 'center',
		width: 900,
		height: 460,
		shadow: false,
		legend:{
			enable:true,
			background_color : null,
			border : {
				enable : false
			}
		},
		background_color: '#ffffff',
		tip: {
			enable: false,
			shadow: true,
			listeners: {
				//tip:提示框对象、name:数据名称、value:数据值、text:当前文本、i:数据点的索引
				parseText: function(tip, name, value, text, i) {
					return "<span style='color:#005268;font-size:12px;'>" + labels[i] + ":00访问量约:<br/>" +
						"</span><span style='color:#005268;font-size:20px;'>" + value + "万</span>";
				}
			}
		},
		sub_option: {
			smooth: false,
			label: false,
			hollow: false,
			hollow_inside: false,
			point_size: 6
		},
		coordinate: {
			width: 640,
			height: 260,
			striped_factor: 0.18,
			gridlinesVisible:false,
			grid_color: '#4e4e4e',
			axis: {
				color: '#252525',
				width: [0, 0, 2, 2]
			},
			scale: [{
				position: 'left',
				scale_size: 2,
				scale_enable: false,
				label: {
					color: '#333333',
					font: '微软雅黑',
					fontsize: 11,
					fontweight: 600
				},
				scale_color: '#9f9f9f'
			}, {
				position: 'bottom',
				label: {
					color: '#333333',
					font: '微软雅黑',
					fontsize: 11,
					fontweight: 600
				},
				scale_enable: false,
				scale2grid:false,
				offsety:600,
			}]
		}
	});

	//利用自定义组件构造左侧说明文本
	chart.plugin(new iChart.Custom({
		drawFn: function() {
			//计算位置
			var coo = chart.getCoordinate(),
				x = coo.get('originx'),
				y = coo.get('originy'),
				w = coo.width,
				h = coo.height;
			//在左上侧的位置，渲染一个单位的文字
			if($('.chooseAB').is(':checked')){
				chart.target.textAlign('start')
					.textFont('600 11px 微软雅黑')
					.textBaseline('top')
					.fillText(labelb[0], 74, y + h + 50, false, '#333333')
					.textBaseline('top')
					.fillText(labelb[1], w+74 , y + h + 50, false, '#333333')
					.textBaseline('top')
					.fillText(labela[0], 74, y + h + 8, false, '#333333')
					.textBaseline('top')
					.fillText(labela[1], w+74 , y + h + 8, false, '#333333')
					.textBaseline('top')
					.textFont('600 14px 微软雅黑')
					.fillText(data[0].texta, x + w + 12, y,false,'#3e576f')
					.textBaseline('top')
					.textFont('600 14px 微软雅黑')
					.fillText(data[1].textb, x + w + 12, y+20,false,'#3e576f');
				chart.target.line(x,y+300,x+w,y+300,2,'#252525');
			}else{
				chart.target.textAlign('start')
					.textBaseline('bottom')
					.textFont('600 11px 微软雅黑')
					.fillText('', x - 40, y - 12, false, '#333333')
					.textBaseline('top')
					.fillText(labela[0], 74, y + h + 8, false, '#333333')
					.textBaseline('top')
					.fillText(labela[1], w+74 , y + h + 8, false, '#333333')
					.textBaseline('top')
					.textFont('600 14px 微软雅黑')
					.fillText(data[0].texta, x + w + 12, y,false,'#3e576f');
			}
		}
	}));
	chart.draw();

	var timeFlag = true;

	$(".startDate1").click(function(){
		timeFlag = true;
	});

	$(".endDate1").click(function(){
		timeFlag = true;
	});

	$(".startDate3").click(function(){
		timeFlag = true;
	});

	$(".endDate3").click(function(){
		timeFlag = true;
	});

	$(".startDate5").click(function(){
		timeFlag =  true;
	});

	$(".endDate5").click(function(){
		timeFlag = true;
	});

	$(".startDate1").jeDate({//按片，第一个开始时间
//		dateCell:".startDate1",
		format:"YYYY-MM-DD hh:mm:ss",
		isinitVal:false,
		isTime:true, //isClear:false,
		minDate:"2014-09-19 00:00:00",
		okfun:function(val) {
			if(!timeFlag){
				$(".endDate1").val("");
			}
			if($(".type").val() != '2' && $(".endDate1").val() && timeFlag) { //按小时，时间范围不能超过31天
				var endDate = $(".endDate1").val();
				var startDate = $(".startDate1").val();
				var diff = timeminus(endDate,startDate);
				if(diff > 1*60*60) {
					$(".endDate1").val("");
					alert("按片，时间范围不得超过1小时");
					timeFlag = false;
				}
			}
			if($('.chooseAB').is(':checked') && $(".startDate2").val()){
				var startDate1 = $('.startDate1').val();
				var endDate1 = $('.endDate1').val();
				var startDate2 = $('.startDate2').val();
				if (startDate1 && endDate1) {
					var diff = timeminus(endDate1,startDate1);
					var date2 = timeplus(startDate2,diff);
					$('.endDate2').val(date2);
				}else{
					return 0;
				}
			}

			if(!$(".endDate1").val()) {
				$(".endDate1").val($(".startDate1").val());
			}
		}
	});

	$(".endDate1").jeDate({//按片，第一个结束时间
//        dateCell:".endDate1",
        format:"YYYY-MM-DD hh:mm:ss",
        isinitVal:false,
        isTime:true, //isClear:false,
        minDate:"2014-09-19 00:00:00",
        okfun:function(val) {
			if(!timeFlag){
				$(".endDate1").val("");
			}
			if($(".type").val() != '2' && $(".startDate1").val() && timeFlag) { //按小时，时间范围不能超过31天
				var endDate = $(".endDate1").val();
				var startDate = $(".startDate1").val();
				var diff = timeminus(endDate,startDate);
				if(diff > 1*60*60) {
					$(".endDate1").val("");
					alert("按片，时间范围不得超过1小时");
					timeFlag = false;
				}
			}
        	if($('.chooseAB').is(':checked') && $(".startDate2").val()){
        	var startDate1 = $('.startDate1').val();
			var endDate1 = $('.endDate1').val();
			var startDate2 = $('.startDate2').val();
			if (startDate1 && endDate1) {
				var diff = timeminus(endDate1,startDate1);
				var date2 = timeplus(startDate2,diff);
				$('.endDate2').val(date2);
			}else{
				return 0;
			}
			}
        }
    });

	$(".startDate2").jeDate({//按片，第二个开始时间
//        dateCell:".startDate2",
        format:"YYYY-MM-DD hh:mm:ss",
        isinitVal:false,
        isTime:true, //isClear:false,
        minDate:"2014-09-19 00:00:00",
//        choosefun:function(val) {
//        	if($('.chooseAB').is(':checked')){
//        	var startDate1 = $('.startDate1').val();
//			var endDate1 = $('.endDate1').val();
//			var startDate2 = $('.startDate2').val();
//			if (startDate1 && endDate1) {
//				var diff = timeminus(endDate1,startDate1);
//				var date2 = timeplus(startDate2,diff);
//				$('.endDate2').val(date2);
//			}else{
//				return 0;
//			}
//			}
//        },
        okfun:function(val) {
        	if($('.chooseAB').is(':checked')){
        	var startDate1 = $('.startDate1').val();
			var endDate1 = $('.endDate1').val();
			var startDate2 = $('.startDate2').val();
			if (startDate1 && endDate1) {
				var diff = timeminus(endDate1,startDate1);
				var date2 = timeplus(startDate2,diff);
				$('.endDate2').val(date2);
			}else{
				return 0;
			}
			}
        }
    });

	$(".startDate3").jeDate({//按小时，第一个开始时间
//		dateCell:".startDate1",
		format:"YYYY-MM-DD",
		isinitVal:false,
		isTime:true, //isClear:false,
		minDate:"2014-09-19",
		okfun:function(val) {
			if(!timeFlag){
				$(".endDate3").val("");
			}
			if($(".type").val() != '2' && $(".endDate3").val() && timeFlag) { //按小时，时间范围不能超过31天
				var endDate = $(".endDate3").val();
				var startDate = $(".startDate3").val();
				var diff = timeminus(endDate,startDate);
				if(diff > 31*24*60*60) {
					$(".endDate3").val("");
					alert("按小时，时间范围不得超过31天");
					timeFlag = false;
				}
			}
			if($('.chooseAB').is(':checked') && $(".startDate4").val()){
				var startDate3 = $('.startDate3').val();
				var endDate3 = $('.endDate3').val();
				var startDate4 = $('.startDate4').val();
				if (startDate3 && endDate3) {
					var diff = timeminus(endDate3,startDate3);
					var date4 = dateFormat(timeplus(startDate4,diff),"yyyy-MM-dd");
					$('.endDate4').val(date4);
				}else{
					return false;
				}
			}

			if(!$(".endDate3").val()) {
				$(".endDate3").val($(".startDate3").val());
			}
		}
	});

	$(".endDate3").jeDate({//按小时，第一个结束时间
//		dateCell:".endDate1",
		format:"YYYY-MM-DD",
		isinitVal:false,
		isTime:true, //isClear:false,
		minDate:"2014-09-19",
		okfun:function(val) {
			if(!timeFlag){
				$(".endDate3").val("");
			}
			if($(".type").val() != '2' && $(".startDate3").val() && timeFlag) { //按小时，时间范围不能超过31天
				var endDate = $(".endDate3").val();
				var startDate = $(".startDate3").val();
				var diff = timeminus(endDate,startDate);
				if(diff > 31*24*60*60) {
					$(".endDate3").val("");
					alert("按小时，时间范围不得超过31天");
					timeFlag = false;
				}
			}
			if($('.chooseAB').is(':checked') && $(".startDate4").val()){
				var startDate3 = $('.startDate3').val();
				var endDate3 = $('.endDate3').val();
				var startDate4 = $('.startDate4').val();
				if (startDate3 && endDate3) {
					var diff = timeminus(endDate3,startDate3);
					var date4 = dateFormat(timeplus(startDate4,diff),"yyyy-MM-dd");
					$('.endDate4').val(date4);
				}else{
					return false;
				}
			}
		}
	});

	$(".startDate4").jeDate({//按小时，第二个开始时间
		format:"YYYY-MM-DD",
		isinitVal:false,
		isTime:true, //isClear:false,
		minDate:"2014-09-19",
		okfun:function(val) {
			if($('.chooseAB').is(':checked')){
				var startDate3 = $('.startDate3').val();
				var endDate3 = $('.endDate3').val();
				var startDate4 = $('.startDate4').val();
				if (startDate3 && endDate3) {
					var diff = timeminus(endDate3,startDate3);
					var date4 = dateFormat(timeplus(startDate4,diff),"yyyy-MM-dd");
					$('.endDate4').val(date4);
				}else{
					return false;
				}
			}
		}
	});

	$(".startDate5").jeDate({//按分，第一个开始时间
//		dateCell:".startDate1",
		format:"YYYY-MM-DD hh:mm:ss",
		isinitVal:false,
		isTime:true, //isClear:false,
		minDate:"2014-09-19 00:00:00",
		okfun:function(val) {
			if(!timeFlag){
				$(".endDate5").val("");
			}
			if($(".type").val() != '2' && $(".endDate5").val() && timeFlag) { //按分钟，时间范围不能超过24小时
				var endDate = $(".endDate5").val();
				var startDate = $(".startDate5").val();
				var diff = timeminus(endDate,startDate);
				if(diff > 24*60*60) {
					$(".endDate5").val("");
					alert("按分，时间范围不得超过24小时");
					timeFlag = false;
				}
			}
			if($('.chooseAB').is(':checked') && $(".startDate6").val()){
				var startDate5 = $('.startDate5').val();
				var endDate5 = $('.endDate5').val();
				var startDate6 = $('.startDate6').val();
				if (startDate5 && endDate5) {
					var diff = timeminus(endDate5,startDate5);
					var date6 = timeplus(startDate6,diff);
					$('.endDate6').val(date6);
				}else{
					return false;
				}
			}

			if(!$(".endDate5").val()) {
				$(".endDate5").val($(".startDate5").val());
			}
		}
	});

	$(".endDate5").jeDate({//按分，第一个结束时间
//		dateCell:".endDate1",
		format:"YYYY-MM-DD hh:mm:ss",
		isinitVal:false,
		isTime:true, //isClear:false,
		minDate:"2014-09-19 00:00:00",
		okfun:function(val) {
			if(!timeFlag){
				$(".endDate5").val("");
			}
			if($(".type").val() != '2' && $(".startDate5").val() && timeFlag) { //按分，时间范围不得超过24小时
				var endDate = $(".endDate5").val();
				var startDate = $(".startDate5").val();
				var diff = timeminus(endDate,startDate);
				if(diff > 24*60*60) {
					$(".endDate5").val("");
					alert("按分，时间范围不得超过24小时");
					timeFlag = false;
				}
			}
			if($('.chooseAB').is(':checked') && $(".startDate6").val()){
				var startDate5 = $('.startDate5').val();
				var endDate5 = $('.endDate5').val();
				var startDate6 = $('.startDate6').val();
				if (startDate5 && endDate5) {
					var diff = timeminus(endDate5,startDate5);
					var date6 = timeplus(startDate6,diff);
					$('.endDate6').val(date6);
				}else{
					return false;
				}
			}
		}
	});

	$(".startDate6").jeDate({//按分，第二个开始时间
		format:"YYYY-MM-DD hh:mm:ss",
		isinitVal:false,
		isTime:true, //isClear:false,
		minDate:"2014-09-19 00:00:00",
		okfun:function(val) {
			if($('.chooseAB').is(':checked')){
				var startDate5 = $('.startDate5').val();
				var endDate5 = $('.endDate5').val();
				var startDate6 = $('.startDate6').val();
				if (startDate5 && endDate5) {
					var diff = timeminus(endDate5,startDate5);
					var date6 = timeplus(startDate6,diff);
					$('.endDate6').val(date6);
				}else{
					return false;
				}
			}
		}
	});

    $('.u-downloadCSV').click(function(){
		var obj = document.getElementById('downloadCSV');
        csvDownload(langMsg.statistics_print.printanalysisone,obj,csvData);
	});
 //    $(".startDate2").on('change',function(e){
	// 	startDate1 = $('.startDate1').val();
	// 	endDate1 = $('.endDate1').val();
	// 	startDate2 = $('.startDate2').val();
	// 	if (startDate1 && endDate1) {
	// 		var diff = timeminus(endDate1,startDate1);
	// 		var date2 = timeplus(startDate2,diff);
	// 		$('.endDate2').attr("value",date2);
	// 	}else{
	// 		return false;
	// 	} 
	// });
	var lineurl = getUrl('statistics_getLine');
    $.ajax({  
        type:'get',      
        url: lineurl,
        async : false, 
        dataType: "json", 
        success:function(data){
        	var inhtml = "";
            if (data.resultCode == 200 && data.resultMessage == "OK") {
            	for (var i = 0,len = data.resultObject.length; i < len; i++) {
            		inhtml += '<option value="'+data.resultObject[i].lineId+'">'+data.resultObject[i].lineName+'</option>';
				}
				$('.u-selectLine').append(inhtml);
            }
        },
        error:function(){
            console.log("selectEqByLineId fail");
        }  
    });
    $('.u-xiangmu').on('change',function(e){
    	if ($(this).val() == 1 ||$(this).val() == 2 ) {
    		$('.u-xiangmu2').show();
    	}else{
    		$('.u-xiangmu2').hide();
    	}
    })
	$('.chooseAB').click(function(){
		if($(this).is(':checked')) {
		    $('.startDate2').attr("disabled",false);
			$(".startDate4").attr("disabled",false);
			$(".startDate6").attr("disabled",false);
		}else{
			$('.startDate2').attr("disabled","disabled");
			$('.startDate2').val("");
			$('.endDate2').val("");
			$(".startDate4").attr("disabled", "disabled");
			$(".startDate4").val("");
			$(".endDate4").val("");
			$(".startDate6").attr("disabled", "disabled");
			$(".startDate6").val("");
			$(".endDate6").val("");
		}
	})
	//开始画图
	$('.u-confirmbtn').click(function(){
		csvData['body'] = [];

		var url = getUrl('statistics_print'),
			line,startDate1,endDate1,startDate2,endDate2,type,abFlag,eqNo;
		line = $(".u-selectLine").val();
		if (!line) {
			return false;
		}
		startDate1 = "";
		endDate1 = "";
		startDate2 = "";
		endDate2 = "";

		var selectType = $(".selectType").val();
		if(selectType == "1") {//按片
			startDate1 = $('.startDate1').val();
			endDate1 = $('.endDate1').val();
			startDate2 = $('.startDate2').val();
			endDate2 = $('.endDate2').val();
		}
		if(selectType == "2") {//按小时
			startDate1 = $('.startDate3').val();
			endDate1 = $('.endDate3').val();
			startDate2 = $('.startDate4').val();
			endDate2 = $('.endDate4').val();
		}
		if(selectType == "3") {//按秒
			startDate1 = $('.startDate5').val();
			endDate1 = $('.endDate5').val();
			startDate2 = $('.startDate6').val();
			endDate2 = $('.endDate6').val();
		}

		type = $('.type').val();
        eqNo = $('.type1').val();
        if($('.chooseAB').is(':checked')){
            abFlag = '1';
		}else {
            abFlag = '0';
		}
		if(startDate2 == ''){
            startDate2 = startDate1;
        }

        if(endDate2 == ''){
            endDate2 = endDate1;
        }
        labela[0] = startDate1;
        labela[1] = endDate1;
        
		console.log(line,startDate1,endDate1,startDate2,endDate2,type);
		var mes = getData(line,startDate1,endDate1,startDate2,endDate2,type,url,abFlag,eqNo,selectType);


	})
});

function sel_type() { //选择查询方式(按片，按小时，按秒)后出发时间
	var typeVar = $(".selectType").val();
	if(typeVar == "1") {//按片
		$(".part-changetime").show();
		$(".hour-changetime").hide();
		$(".sec-changetime").hide();
	}

	if(typeVar == "2") {//按小时
		$(".part-changetime").hide();
		$(".hour-changetime").show();
		$(".sec-changetime").hide();

	}

	if(typeVar == "3") {//按秒
		$(".part-changetime").hide();
		$(".hour-changetime").hide();
		$(".sec-changetime").show();

	}
	//清空AB选中状态
	$(".chooseAB").attr("checked", false);
	$('.startDate2').attr("disabled","disabled");
	$('.startDate2').val("");
	$('.endDate2').val("");
	$(".startDate4").attr("disabled", "disabled");
	$(".startDate4").val("");
	$(".endDate4").val("");
	$(".startDate6").attr("disabled", "disabled");
	$(".startDate6").val("");
	$(".endDate6").val("");
}

function getData(line,startDate1,endDate1,startDate2,endDate2,type,url,abFlag,eqNo,selectType){
    $(".loading").show();
    var res = null;
    $.ajax({  
        type:'get',      
        url: url,
        async : false, 
        dataType: "json",
        data:{"line":line,"startDate1":startDate1,"endDate1":endDate1,"startDate2":startDate2,"endDate2":endDate2,"type":type,"eqNo":eqNo,"abFlg":abFlag, "selectType":selectType},
        success:function(mes){
            $(".loading").hide();
            var aaa = [0],
                bbb = [0];
            if (mes.resultCode == 200 && mes.resultMessage == "OK") {
                res = mes;
                console.log(mes);
                if($('.chooseAB').is(':checked')){
                    labelb[0] = startDate2;
                    labelb[1] = endDate2;
                    for (var i = 0,len = mes.resultObject.aList?mes.resultObject.aList.length:0; i < len; i++) {
                        aaa[i] = mes.resultObject.aList[i].yValue;
                        csvData['body'].push([line,$('.type1').val(),,"印刷机",mes.resultObject.aList[i].WAFER_ID,$('.type option:selected').text(),mes.resultObject.aList[i].yValue,mes.resultObject.aList[i].xValue]);
                    }
                    for (var i = 0,len = mes.resultObject.bList?mes.resultObject.bList.length:0; i < len; i++) {
                        bbb[i] = mes.resultObject.bList[i].yValue;
                        csvData['body'].push([line,$('.type1').val(),,"印刷机",mes.resultObject.bList[i].WAFER_ID,$('.type option:selected').text(),mes.resultObject.bList[i].yValue,mes.resultObject.bList[i].xValue]);
                    }
                    var aAvg2 = parseFloat(mes.resultObject.aAvg).toFixed(2);
                    var bAvg2 = parseFloat(mes.resultObject.bAvg).toFixed(2);

                    var difff1 = timeminus(endDate1,startDate1),
                        difff1b = timeminus(endDate2,startDate2),
                        difff2 = mes.resultObject.aList[0]?timeminus(mes.resultObject.aList[mes.resultObject.aList.length-1].xValue,mes.resultObject.aList[0].xValue):0,
                        difff3 = mes.resultObject.aList[0]?timeminus(mes.resultObject.aList[0].xValue,startDate1):0,
                        difff2b = mes.resultObject.bList[0]?timeminus(mes.resultObject.bList[mes.resultObject.bList.length-1].xValue,mes.resultObject.bList[0].xValue):0,
                        difff3b = mes.resultObject.bList[0]?timeminus(mes.resultObject.bList[0].xValue,startDate2):0;
                    var per1 = (parseInt(difff3)/parseInt(difff1)),
                        per1b = (parseInt(difff3b)/parseInt(difff1b)),
                        per3 = (parseInt(difff2)/parseInt(difff1))
                    per3b = (parseInt(difff2b)/parseInt(difff1b));

                    var xnum;
                    if (mes.resultObject.aList.length >= mes.resultObject.bList.length) {
                        xnum = mes.resultObject.aList.length/per3;
                    }else{
                        xnum = mes.resultObject.bList.length/per3b;
                    }

                    var leftnum = parseInt(Math.round(xnum)*per1);
                    var rightnum = Math.round(xnum) - leftnum -mes.resultObject.aList.length;

                    var leftnumb = parseInt(Math.round(xnum)*per1b);
                    var rightnumb = Math.round(xnum) - leftnumb -mes.resultObject.bList.length;

                    console.log(leftnum,rightnum,leftnumb,rightnumb,xnum);
                    for (var i = 0; i < leftnum; i++) {
                        aaa.unshift(null);
                    }
                    for (var i = 0; i < rightnum; i++) {
                        aaa.push(null);
                    }
                    for (var i = 0; i < leftnumb; i++) {
                        bbb.unshift(null);
                    }
                    for (var i = 0; i < rightnumb; i++) {
                        bbb.push(null);
                    }
                    console.log(aaa,bbb)
                    data = [{
                        name: 'A片',
                        value: aaa,
                        color: '#0d8ecf',
                        line_width: 2,
                        texta:"平均值A："+aAvg2
                    }, {
                        name: 'B片',
                        value: bbb,
                        color: '#ef7707',
                        line_width: 2,
                        textb:"平均值B："+bAvg2
                    }];
                }else {
                    for (var i = 0,len = mes.resultObject.aList?mes.resultObject.aList.length:0; i < len; i++) {
                        aaa[i] = mes.resultObject.aList[i].yValue;
                        csvData['body'].push([line,$('.type1').val(),"印刷机",mes.resultObject.aList[i].WAFER_ID,$('.type option:selected').text(),mes.resultObject.aList[i].yValue,mes.resultObject.aList[i].xValue]);
                    }
                    var aAvg2 = parseFloat(mes.resultObject.aAvg).toFixed(2);
                    var difff1 = timeminus(endDate1,startDate1),
                        difff2 = mes.resultObject.aList[0]?timeminus(mes.resultObject.aList[mes.resultObject.aList.length-1].xValue,mes.resultObject.aList[0].xValue):0,
                        difff3 = mes.resultObject.aList[0]?timeminus(mes.resultObject.aList[0].xValue,startDate1):0;
                    var per1 = (parseInt(difff3)/parseInt(difff1));
                    var per3 = (parseInt(difff2)/parseInt(difff1));
                    var xnum = mes.resultObject.aList.length/per3;
                    var leftnum = parseInt(xnum*per1);
                    var rightnum = Math.round(xnum) - leftnum -mes.resultObject.aList.length;
                    console.log(leftnum,rightnum,xnum);
                    for (var i = 0; i < leftnum; i++) {
                        aaa.unshift(null);
                    }
                    for (var i = 0; i < rightnum; i++) {
                        aaa.push(null);
                    }
                    data = [{
                        name: '总线',
                        value: aaa,
                        color: '#3aa3a3',
                        line_width: 2,
                        texta:"平均值A："+aAvg2
                    }];

                }
                chart.load(data);
            }
        },
        error:function(){
            $(".loading").hide();
        	alert('获取数据失败')
            console.log("fail");
        }  
    });
    return res;
}
</script>

</body>
</html>